// components/comment-cell/index.js
const app = getApp()

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    focus:false,
    len:0,
    showComment:false,
    form:{
      content:""
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    formSubmit(e){
      let obj = e.detail.value;
      if (obj.evaluateContent.trim() == ""){
        wx.showToast({
          title:"评论不能为空",
          icon:"none"
        });
        return false;
      }
      let  myEventOption = {};
      this.triggerEvent('sendComment', obj, myEventOption);
      this.colseComment();
    },
    formReset(){},
    inputComment(e){
      let val = e.detail.value.trim();
      this.setData({
        len:val.length
      })
    },
    openComment(){
      //校验登录
      if (app.checkLogin()){
        this.setData({
          showComment:true,
        })
      }
    },
    colseComment(){
      this.setData({
        showComment: false,
        len:0,
        focus: false,
        "form.content":""
      })
    }
  }
})
